
/**
 * Created by xiongshilin on 2017/4/14.
 */
ADF.domControl.BootstrapContainer = function(parent) {
    ADF.domControl.BootstrapContainer.superclass.constructor.call(this, parent);
    this.feedbackDom = null;
};

COM.util.defineClass(ADF.domControl.BootstrapContainer, ADF.domControl.Composite, {
    getLabel: function(){
        return "Container";
    },
    appendDomChild: function(child) {
        this.getDomElement().children[0].appendChild(child);
        //this.getDomElement().appendChild(child);
    },
    removeDomChild: function(child) {
        this.getDomElement().children[0].removeChild(child);
        //this.getDomElement().removeChild(child);
    },
    _getDomElement: function(model) {
        var containerWrap = this.createContainerWrap(model);
        var container = this.createContainer(model);
        containerWrap.append(container);
        this.domElement = containerWrap[0];
        return this.domElement;
    },
    createContainerWrap: function(model) {
        var containerWrap = COM.util.HTMLUtil.createELement('<div class="bootstrapWrap containerWrap adf_wrapper"></div>');
        return containerWrap;
    },
    createContainer: function(model) {
        var container = COM.util.HTMLUtil.createELement('<div class="container"></div>');
        var css = {"position":"relative",
            "overflow":"visible",
            "width":"100%",
            /*"background-color":"rgba(89,89,89,1)"*/};
        css.minHeight = 100;
        container.css(css);
        return container;
    },
    showFeedback: function(height) {
        var css = {"position":"relative", "overflow":"visible", "border":"1px dashed #808080"};
        if(this.feedbackDom == null) {
            var row = COM.util.HTMLUtil.createELement('<div class="bootstrapWrap rowWrap adf_wrapper"><div class="row"></div></div>');
            this.feedbackDom = row[0];
        }
        if(height>0) {
            css.height = height;
        } else {
            css.minHeight = 60;
        }
        COM.util.HTMLUtil.getJqueryDOM(this.feedbackDom).css(css);
        this.domElement.children[0].appendChild(this.feedbackDom);
        return COM.util.HTMLUtil.getBounds(this.feedbackDom);
    },
    eraseFeedback: function() {
        if(COM.util.HTMLUtil.hasChild(this.domElement, this.feedbackDom)) {
            this.domElement.children[0].removeChild(this.feedbackDom);
        }
    },
    layoutChild : function(child){
        var childDom = child.getDomElement();
        var layoutData = child.getLayoutData();
        if(layoutData){
            var css = {"display":"block", "height":layoutData};
            $(childDom).css(css);
        }
    }
});